<?php
	include ("jpgraph/jpgraph.php");
	include ("jpgraph/jpgraph_pie.php");
	include ("jpgraph/jpgraph_pie3d.php");
	//drawing graph

	//error_log($_REQUEST["data"]);
	$catexp = unserialize(stripslashes($_REQUEST["data"]));
	//error_log(print_r($catexp, true));
	$cats = array();
	$catnames = array();
	$catcolor = array();
	if(is_array($catexp)) {
		foreach($catexp as $category => $exp) {
			$cats[] = $exp[0];
			$catnames[] = $category;
			$catcolor[] = $exp[1];
		}
	}


	$graph = new PieGraph(600,600,"auto");
	$graph->SetShadow();

	$graph->title->Set("Expense");
	$graph->title->SetFont(FF_FONT1,FS_BOLD,24);

	//$graph->title->SetFont(FF_TIMES,FS_NORMAL,15);
	$p1 = new PiePlot($cats);

	$p1->SetCenter(0.45);
	$p1->SetLegends($catnames);
	$p1->SetSliceColors($catcolor);

	$p1->SetGuideLines(true,false);
	$p1->SetGuideLinesAdjust(1.1);

	$p1->SetLabelType(PIE_VALUE_PER);
	$p1->value->Show();
	$p1->value->SetFont(FF_ARIAL,FS_NORMAL,9);
	$p1->value->SetFormat('%2.1f%%');

	$graph->Add($p1);
	$graph->Stroke();
?>
